package com.inforich.screenData.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.inforich.common.utils.DateUtils;
import com.inforich.screenData.domain.ReportView;
import com.inforich.screenData.mapper.ReportViewMapper;
import com.inforich.screenData.service.IReportViewService;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;

/**
 * 数据总览Service业务层处理
 *
 * @author hjm
 * @date 2022-10-26
 */
@Service
public class ReportViewServiceImpl extends ServiceImpl<ReportViewMapper, ReportView> implements
    IReportViewService {

  @Override
  public Page<ReportView> pageReportView(Page<ReportView> page, Map<String, Object> map) {
    return baseMapper.pageReportView(page, map);
  }

  @Override
  public List<ReportView> listReportView(Map<String, Object> map) {
    return baseMapper.listReportView(map);
  }

  @Override
  public Boolean checkConflict(ReportView reportView) {
    return this.count(new LambdaQueryWrapper<ReportView>()
        .eq(ReportView::getStatisticsDate,
            DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, reportView.getStatisticsDate()))
        .ne(reportView.getId() != null, ReportView::getId, reportView.getId())) > 0;
  }


}
